﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using DbLibrary;

namespace DbLibrary.DataBase
{
    public class UserRepository : RepositoryBase<Models.User, User>
    {
        protected override Table<User> GetTable()
        {
            return context.Users;
        }

        protected override Expression<Func<User, Models.User>> GetConverter()
        {
            return c => new Models.User()
            {
                Id = c.Id,
                RoleId = c.RoleId,
                UserName = c.UserName, 
                Password = c.Password
            };
        }

        protected override void UpdateEntry(User dbUser, Models.User user)
        {
            dbUser.RoleId = user.RoleId;
            dbUser.UserName = user.UserName;
            dbUser.Password = user.Password;
        }
    }
}
